package com.tianzhu.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;


/**
 * The persistent class for the CART database table.
 * 
 */
@Entity
@Table(name="CART")
@NamedQuery(name="Cart.findAll", query="SELECT c FROM Cart c")
public class Cart implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="CART_CARTID_GENERATOR", sequenceName="CART_S")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CART_CARTID_GENERATOR")
	@Column(unique=true, nullable=false, precision=38)
	private Long cartid;

	@OneToOne
	@JoinColumn(name = "CUSTOMERID")
	@JsonIgnore
	private Customer customer;

	@Column(name="GRANDTOTAL",precision=126)
	private double grandtotal;
	
	@OneToMany(mappedBy = "cart", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<Cartitem> cartItems;

	public Cart() {
	}

	public Long getCartid() {
		return this.cartid;
	}

	public void setCartid(Long cartid) {
		this.cartid = cartid;
	}

	
	public double getGrandtotal() {
		return this.grandtotal;
	}

	public void setGrandtotal(double grandtotal) {
		this.grandtotal = grandtotal;
	}
	
	public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }
    
    public List<Cartitem> getCartItems() {
        return cartItems;
    }

    public void setCartItems(List<Cartitem> cartItems) {
        this.cartItems = cartItems;
    }

}